package xyz.wanwanwan.www.hrm.receive;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import xyz.wanwanwan.www.hrm.config.RabbitmqConfig;

import java.io.IOException;
@Component
public class CourseMQReceiveMessage {
    @RabbitListener(queues = RabbitmqConfig.QUEUE_INFORM_SMS)
    public void listenSMS(String msg, Message message, Channel channel) throws IOException {
        System.out.println("收到短信:"+ JSON.parseObject(msg));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
    @RabbitListener(queues = RabbitmqConfig.QUEUE_INFORM_EMAIL)
    public void listenEmail(String msg, Message message, Channel channel) throws IOException {
        System.out.println("收到邮件:"+JSON.parseObject(msg));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
    @RabbitListener(queues = RabbitmqConfig.QUEUE_INFORM_INNER)
    public void listenSystem(String msg, Message message, Channel channel) throws IOException {
        System.out.println("保存站内信:"+JSON.parseObject(msg));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
